#include "BaseSample.h"


CBaseSample::CBaseSample()
{
	m_fReleaseListener = nullptr;
}


CBaseSample::~CBaseSample()
{
}

int CBaseSample::Release()
{
	lock();
	if (m_nRef > 0) {
		m_nRef--;

		if (m_nRef == 0 && m_fReleaseListener != nullptr) {
			m_fReleaseListener(this);
		}
	}

	if (m_nRef == 0) {
		unlock();
		delete this;

		return 0;
	}
	else {
		unlock();
	}

	return m_nRef;
}

int CBaseSample::encoding(char * pszBuffer, const int nBufferSize)
{
	return 0;
}

int CBaseSample::decoding(const char * pBuffer, const int nBufferSize)
{
	return 0;
}

void CBaseSample::SetReleaseListener(RELEASELISTENER listener)
{
	m_fReleaseListener = listener;
}
